﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;

namespace SimpleSample
{
    class Program
    {
        static void Main(string[] args)
        {
            LoginFailedException e = new LoginFailedException();
            e.LoginUserName = "dotnet user";

            using (Stream s = new MemoryStream())
            {
                BinaryFormatter formatter = new BinaryFormatter();
                formatter.Serialize(s, e);
                s.Position = 0; // Reset stream position
                e = (LoginFailedException)formatter.Deserialize(s);
            }

            if (string.Equals(e.LoginUserName, "dotnet user"))
            {
                Console.Write("Good");
            }
        }
    }
}
